﻿using System;
using System.Windows.Forms;
using Autofac;
using DataBaseLayer.Abstractions;
using DataBaseLayer.Factories;
using DocumentManager.Abstractions.Factories;
using DocumentManager.Enums;
using DocumentManager.Factories;
using GrigSoft.Managers.Abstractions.Interfaces.IO;
using GrigSoft.Managers.IO;

namespace DocumentManager
{
	static class Program
	{
		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main()
		{
			try
			{
				Application.EnableVisualStyles();
				Application.SetCompatibleTextRenderingDefault(false);

				var builder = new ContainerBuilder();

				builder.RegisterType<FileManager>().As<IFileManager>();
				builder.RegisterType<HelperFactory>().As<HelperBaseFactory>();
				builder.RegisterType<ServiceFactory>().As<ServiceBaseFactory>();
				builder.RegisterType<FormFactory>().As<FormBaseFactory>();

				var container = builder.Build();
			
				Application.Run(container.Resolve<FormBaseFactory>().CreateForm(FormType.Login));
			}
			catch (Exception ex)
			{
				MessageBox.Show(string.Format("Ошибка работы приложения{0}{1}", Environment.NewLine, ex.Message));
			}
		}
	}
}
